#ifndef FILETREE_H
#define FILETREE_H

#include <QWidget>
#include <QTreeWidget>
#include <QAction>

QT_BEGIN_NAMESPACE
class QTextBrowser;
class HexWidget;
QT_END_NAMESPACE

class FileTree : public QWidget
{
    Q_OBJECT

public:
    FileTree(QWidget *parent = nullptr);
    ~FileTree();

    bool setFile(const QString &fileName, const QString &dllPath);
    void closeFile(void);
    void setFindBytes(QByteArray data);

signals:
    void selectChanged(int pos, int len);
    void onMessage(const QString &text, int timeout = 0);

public slots:
    void copy();
    void findNext();
    void findLast();

private slots:
    void onHexSelect(qint64 pos);
    void onTreeSelect(QTreeWidgetItem *item, int column);
    void onPauseError(int line);
    void onPauseLog(int type, QString log);

private:
    void initWidget(void);
    bool parseData(QByteArray &data, const QString &dllPath);
    QTreeWidgetItem *getHexSelectItem(QTreeWidgetItemIterator it, qint64 pos);

private:
    QTreeWidget *m_tree;
    HexWidget *m_hex;
    QTextBrowser *m_log;
    QByteArray m_findBytes;
};

#endif // FILETREE_H
